package com.cdut.drivingschool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.cdut.drivingschool.DrivingApplication;
import com.cdut.drivingschool.R;
import com.cdut.drivingschool.bean.School;
import com.cdut.drivingschool.view.MyRatingBar;
import com.nostra13.universalimageloader.core.ImageLoader;

public class SchoolListAdapter extends BaseGroupAdapter<School>{

	public SchoolListAdapter(Context context) {
		super(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null){
			convertView = LayoutInflater.from(getContext()).inflate(R.layout.school_list_item, null);
		}
		School school = getGroup().get(position);
		TextView mName = ViewHolder.get(convertView, R.id.school_name);
		mName.setText(school.school_name);
		ImageView mLogo = ViewHolder.get(convertView, R.id.school_logo);
		ImageLoader.getInstance().displayImage(school.school_logo, mLogo, DrivingApplication.options);
		ImageView mIsPrivilege = ViewHolder.get(convertView, R.id.is_privilege);
		if(school.school_youhuilogo == 1){
			mIsPrivilege.setVisibility(View.VISIBLE);
		}else{
			mIsPrivilege.setVisibility(View.INVISIBLE);
		}
		TextView mCollege = ViewHolder.get(convertView, R.id.college);
		mCollege.setText(school.college);
		TextView mBranch = ViewHolder.get(convertView, R.id.school_branch);
		mBranch.setText(school.school_branch);
		TextView mPrice = ViewHolder.get(convertView, R.id.school_price);
		mPrice.setText("￥"+school.school_newprice);
		MyRatingBar mRating = ViewHolder.get(convertView, R.id.pinfen);
		mRating.setRating(school.school_pinfen);
		return convertView;
	}


}
